1. Field of the Invention
The present invention generally relates to a method and an apparatus for generating a coded block pattern for highpass coefficients, and more particularly, to a method and an apparatus for generating a coded block pattern for highpass coefficients capable of reducing the number of operation clock cycles and the number of coefficient accesses.
2. Description of Related Art
An image compression coding is usually implemented by transforming and compression encoding a raw image data to generate an encoded stream, where the image compression coding procedure also includes performing sampling and color space transforming.
Taking the JPEG format standard as an example, the image compression coding procedure includes transforming the colors of a raw image data onto the YCbCr color space, performing discrete cosine transform (DCT), quantization processing, performing prediction difference on the DC coefficients, scanning the coefficients into a run-length encoded data in zig-zag scan sequence and finally performing variable length coding to complete encoding the above-mentioned JPEG data.
The Microsoft Co. in WA, US has designed a new still-image compression file format, termed as HD Photo format. The JPEG International Standard committee has considered Microsoft's HD Photo format as a new standard called JPEG XR. In order to reduce the block effect introduced by an independence block transform, the HD Photo format adopts lapped transform (LT) scheme based on a 4×4 block as an unit, wherein an overlap filtering is performed on the 4×4 blocks located at the common boundaries between blocks, followed by performing core transform on the 4×4 blocks. The overlap filtering and the core transform herein utilize a lifting scheme to ensure a lossless compression. After the LT, a quantization processing and a coefficient-predicting procedure are performed to generate a coded block pattern. After the coded block pattern is generated, adaptive scanning and entropy coding are carried out to generate an encoded stream.
Every step of the above-mentioned image-lifting architecture is entirely reversible. Therefore, if the coding procedure is performed on a lossless compression transform signal, it is allowed to perform a reversible core transform during decoding first, followed by a reversible overlap filtering. As a result, an identical picture with the original one can be obtained. The HD Photo format allows people to self-determine whether to perform an overlap filter transform of the first stage and an overlap filter transform of the second stage. The obtained DC coefficients and AC coefficients are quantized, and then the entropy coding and a packetization processing are performed on the quantized coefficients such that a compressed bit stream can be obtained.
The specification of the HD Photo format has considerable differences from the JPEG format. In particular, the HD Photo format allows a pixel value domain having a larger range, uses a newly-defined YCoCg color space, a newly-defined lapped-transforms of two stages and a newly-defined coefficient prediction operation.
Prior to perform the entropy coding on the transform coefficients, a block pattern coding needs to be carried out first. However, the coded block pattern is the information indicating that whether the normalized coefficients of each metablock are all zoro, where the normalized coefficients are generated by quantizing, coefficient predicting and then normalizing the coefficients of the metablock. Furthermore, after performing the transform and the quantization, a coefficient prediction and a normalization and then extracting the coded block pattern information are performed. Only finishing the above-mentioned steps, an entropy coding on the coefficients can be performed. It is obvious that the operation of calculating the coded block pattern would increase the number of operation clock cycles and the burden for a memory to be accessed.
FIG. 1 is block diagram showing a compression coding flowchart of a still-image in HD Photo format. Referring to FIG. 1, after performing a color transform of an image, a lapped transform operation of the first stage 110 and a lapped transform operation of the second stage 120 are performed on the image, wherein the calculating results of the lapped transform operation of the first stage 110 are inputted into the lapped transform operation of the second stage 120. Then, the DC coefficients (shortly termed as ‘DC’), lowpass coefficients (shortly termed as ‘LP’) and highpass coefficients (shortly termed as ‘HP’) are generated according to the two-stage lapped transform. Thereafter, quantization operations 130, 132 and 134 are performed respectively on the DCs 122, the LPs 124 and the HPs 126; after that, a DC prediction direction operation 140, an LP prediction direction operation 142 and a HP prediction direction operation 144 are performed. Then, an entropy coding operation 150 is performed according to the results of 140, 142 and 144, wherein the entropy coding operation 150 includes coefficient normalization, adaptive scan, variable length coding, etc.
FIG. 2 is a diagram illustrating the coefficients of a macroblock of an image data in YUV—4:4:4 format are obtained by using transform, quantization and coefficient prediction. Referring to FIG. 2, a macroblock 210 herein represents an Y (luma) macroblock, a U (chroma) macroblock or a V (chroma) macroblock. A transform of the first stage on the macroblock 210 is performed and then 16 metablocks 220 are obtained, wherein each metablock includes one DC 222 and 15 HPs 224. Then, the 16 DCs obtained in the transform of the first stage are arranged to compose a 4×4 block. After that, an LT of the second stage on the 4×4 block is performed so as to obtain a new block 230, wherein the block 230 consists of one DC 232 and 15 LPs 234. In terms of the LTs on a macroblock of an image data in YUV—4:2:2 format or YUV—4:2:0 format, the procedures are similar to that of FIG. 2.
Prior to performing an entropy coding on HPs however, the coded block pattern thereof must be obtained. A coded block pattern for HPs of YUV—4:4:4 format has 48 bits in total, wherein each bit respectively represents one of the 16 metablocks of an Y macroblock, the 16 metablocks of a U macroblock and the 16 metablocks of a V macroblock. The bit value ‘0’ herein means all the HPs of a metablock after performing the quantization, the coefficient prediction and the normalization are all-zero; otherwise, the bit value is ‘1’.
The coefficient prediction direction utilizes the above-mentioned macroblock as a unit. The DC prediction direction of a macroblock is decided by the DC values of the macroblock at the left edge, the upper-left corner and the upper edge. The LP prediction direction of a macroblock is decided by the DC prediction direction and the quantization parameter. In other words, the DC prediction direction and the LP prediction direction can be decided prior to the LT on the same macroblock. In contrast, the HP prediction direction is obtained after calculating the LPs of the same macroblock; however, the LPs are obtained after performing the transform of the second stage, which is shown in FIG. 3, after the transform of the second stage, a HP prediction direction is calculated with the LPs and then the HPs are extracted to calculate the coded block pattern for HPs. In FIG. 3, after performing the LTs 310 of the two stages, the generated LPs are used to calculate the HP prediction direction 320, then calculate the coded block pattern 330 for HPs and finally perform an entropy coding 340 on the HPs.
Such an architecture would increase the number of operation clock cycles and the number of coefficient accesses, which reduces the efficiency of processing data.